package com.login.dao.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.login.bean.Buyer;
import com.login.dao.IManagerDao;
import com.login.utils.DbUtils;


public class ManagerDaoImpl implements IManagerDao {

	@Override
	public boolean ManagerLogin(String username, String password) {
		String sql="select * from tb_manager where name=? and password=?";
		PreparedStatement ps=DbUtils.executePrepareStetement(sql);
		try {
			
			ps.setString(1, username);
			ps.setString(2, password);
			ResultSet rs=ps.executeQuery();
			if(rs.next()){
				if(rs.getString("name").equals(username)&&rs.getString("passWord").equals(password));
				return true;
			}
		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		
		return false;
	}


	@Override
	public List<Buyer> findAllSeller() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Buyer> findType(String userType) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Buyer findByUsername(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateManager(String userpwd, String name) {
		String sql="update tb_manager set passWord=? where name=?";
		PreparedStatement ps=DbUtils.executePrepareStetement(sql);
		int rs=0;
		try {
			ps.setString(1, userpwd);
			ps.setString(2, name);			
			rs=ps.executeUpdate();
		} catch (SQLException e) {			
			e.printStackTrace();
		}
		return rs;
	}



}
